package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Mobile   string `gorm:"type:char(11);unique;comment:手机号"`
	Password string `gorm:"type:char(32);comment:密码"`
	Status   string `gorm:"type:tinyint(1);default:2;comment:状态1:正常,2:冻结"`
}
type RealName struct {
	gorm.Model
	UserId   int64  `gorm:"type:int(11);comment:用户id"`
	RealName string `gorm:"type:char(3);comment:姓名"`
	IdCord   string `gorm:"type:char(18);comment:身份证"`
	Checked  int64  `gorm:"type:tinyint(1);default:1;comment:状态1:待通过,2:通过,3:未通过,"`
}

func (u *User) Create() error {
	return Db.Create(&u).Error
}
func (u *User) UserInfo(mobile string) error {
	return Db.Where("mobile = ?", mobile).Limit(1).Find(&u).Error
}
func (r *RealName) RealNameInfo(userId int64, realName string) error {
	return Db.Debug().Model(&r).Where("user_id = ? or real_name = ?", userId, realName).Limit(1).Find(&r).Error
}
func (r *RealName) CreateInfo() error {
	return Db.Create(&r).Error
}
func (r *RealName) UpdateChecked() error {
	return Db.Model(&r).Where("user_id = ?", r.UserId).Update("checked ", r.Checked).Error
}
